package utils;


import db.DBDruidManager;

import java.sql.*;
import java.util.Scanner;

/**
 * @author 谢成林
 * */
public class LogUtil {
    private static Connection connection;

    /*   static {
         connection = DBDruidManager.getConnection();
    }
    public static void log(String userId, LogOperateEnum logOperateEnum,String result){

        String sql = "insert into log (user_id,time,operate,result) values(?,now(),?,?)";
        try {
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            Object [] param = new Object[3];
            param[0] = userId;
            param[1] = logOperateEnum.getValue();
            param[2] = result;


            JDBCUtil.handleParamsForPreparedStatement(preparedStatement,param);
            preparedStatement.executeUpdate();

        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            DBDruidManager.closeConnection();
        }


    }*/
    
    
//使用druid添加日志
    public static void log(String userId, LogOperateEnum logOperateEnum,String result){

        String sql = "insert into log (user_id,time,operate,result) values(?,now(),?,?)";
        connection = DBDruidManager.getConnection();
        PreparedStatement ps = null;
        try {
            
            Object [] param = new Object[3];
            param[0] = userId;
            param[1] = logOperateEnum.getValue();
            param[2] = result;
            ps = connection.prepareStatement(sql);
            JDBCUtil.handleParamsForPreparedStatement(ps, param);
            ps.execute();
        } catch (Exception e) {
        	UserLogUtil.log("===========UserLogUtil ERROR INFO==============");
            e.printStackTrace();
        } finally {
            DBDruidManager.closeConnection();
        }


    }
    
    
    public static  int countNum(int result){

        int min=result;
        if(result%2==1) return -1;
        else{
            for(int i=1;i<result/6;i++){
                if((result-6*i)%8==0){
                    int j=(result-6*i)/8;
                    min=min>(i+j)?(i+j):min;
                }
            }
        }

        return min;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            int n = scanner.nextInt();
            Log4jInit.logger.info("%d",countNum(n));
        }

    }
}



